Skip to content

fix: Align context bundle traversal with effective-dep-graph semantics#85

Open
ulascanzorer wants to merge 2 commits into
mainfrom
fix/mymr-207-align-context-bundle-traversal
Open

fix: Align context bundle traversal with effective-dep-graph semantics#85
ulascanzorer wants to merge 2 commits into
mainfrom
fix/mymr-207-align-context-bundle-traversal

Conversation

@ulascanzorer
Copy link
Copy Markdown
Collaborator

Summary

Task Reference: [MYMR-207]

The three context-bundle builders (buildAgentContext, buildPlanningContext, buildReviewContext) built their Prerequisites and Downstream sections from raw recursive CTEs (getDependencyChain, getDownstreamTx) that predated the cancelled-transparent semantics buildEffectiveDepGraph already enforces for the analyze tools. As a result bundles listed cancelled tasks as prerequisites/dependents, and a cancelled middle on a depends_on path burned a depth slot so the real active blocking wall was never reached inside the maxDepth=2 budget (A -> B(cancelled) -> C(active) showed B at depth 1 and never reached C).

This change derives prerequisites and downstream from a depth-bounded walk over the effective graph so the four analyze tools and the three context bundles agree semantically for the same task:

  • Extracted the traversal substrate (listTasksForGraph + listDependsOnEdges + adjacency build) into a new exported buildDepAdjacency in lib/graph/effective-deps.ts, and refactored buildEffectiveDepGraph to call it (behaviour unchanged; getBlockedTasks/getCriticalPath/deriveTaskStatesSlim see no difference).
  • Added a new exported walkEffectiveDepsBounded: a BFS-by-effective-depth walk where cancelled tasks are transparent and depth-free, capped at the bundle budget of depth 2.
  • Switched agent.ts/planning.ts/review.ts off getDependencyChain/getDownstreamTx onto one buildDepAdjacency call plus forward (prerequisites) and reverse (downstream) bounded walks. lib/data/traversal.ts is untouched; its other callers (getDownstream, edge.ts cycle detection) are unaffected.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation

Testing

  • Tested locally with bun run dev
  • Linting passes (bun run lint)
  • Typecheck passes (bun run typecheck)

Full bun test suite green (461 pass, 0 fail). Added a cancelled-middle transparency integration test to each of tests/context/agent.test.ts, tests/context/planning.test.ts, tests/context/review.test.ts asserting C surfaces and B (cancelled) does not.

Notes for reviewer

  • The bounded walk is intentionally capped at depth 2 (the existing bundle budget) while the analyze tools use the unbounded effective closure. That depth bound is the locked design decision: consistency here is semantic (cancelled-transparency, active-only nodes), not identical traversal depth.
  • Tracked follow-up, deliberately out of scope: mymir_analyze type='downstream' (getDownstream -> getDownstreamTx -> fetchDownstream) still uses the raw cancelled-blind CTE and carries the same bug class. Left for a separate task per MYMR-207 scope; no change to getDownstream/getDownstreamTx/fetchDownstream/tool-handlers.ts here.

@ulascanzorer ulascanzorer requested review from FrkAk and ZeyNor as code owners May 18, 2026 20:53
@FrkAk FrkAk changed the title fix: Align context bundle traversal with effective-dep-graph semantics [MYMR-207] fix: Align context bundle traversal with effective-dep-graph semantics May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant